<?php

namespace app\controller;

use app\service\TaskWorkOrderService;
use support\Request;
use support\Response;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;


class WorkOrderStatisticsController
{
    //工单统计服务
    protected $taskWorkOrderService;

    public function __construct()
    {
       $this->taskWorkOrderService =  TaskWorkOrderService::getInstance();
    }


    /**
     * 工单统计
     * @param Request $request
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function workOrderStatistics(Request $request): Response
    {
        $param     = $request->post()['param'];
        $tenant_id = $request->getTenantId();
        $response  = $this->taskWorkOrderService->getTaskWorkOrderStatistics($param, $tenant_id);

        return json(success_response('success', $response));
    }

}
